/**
 * @description 
 * 程序说明：
 * @pageNo 
 * @author mlmoria
 * @date 2017年2月13日
 * 
 */
package No12Net.Chart.DIY;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.Socket;

public class ChartClientDIY {

	public static void main(String[] args) {
		try {
			
		
			Socket socket=new Socket("127.0.0.1",8080);
			//OutputStream os=socket.getOutputStream();
			//writeToClient(os);
			InputStream is=socket.getInputStream();
			readFromClient(is);   
			is.close();
			//os.close();	
			socket.close();
		
				
			
		
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	public static void  readFromClient(InputStream is){
		Reader reader=new InputStreamReader(is);
		BufferedReader br =new BufferedReader(reader);
		String s=null;
		try {
			while((s=br.readLine())!=null){
				System.out.println("服务端说："+s);	
			}
		br.close();
		reader.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	public static void  writeToClient(OutputStream os){
		Writer writer=new OutputStreamWriter(os);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		try {
			System.out.println("请输入：");
			String s= br.readLine();
			writer.write(s);
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
